package com.ruoyi.project.ins.domain;

import com.ruoyi.framework.aspectj.lang.annotation.Excel;
import com.ruoyi.framework.web.domain.BaseEntity;
import lombok.Builder;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;

import java.util.HashMap;

@EqualsAndHashCode(callSuper = true)
@Data
@NoArgsConstructor
public class InsMessage extends BaseEntity {
    private static final long serialVersionUID = 1L;

    private Long id;

    @Excel(name = "发送方账号", type = Excel.Type.ALL)
    private String sendUsername;

    @Excel(name = "发送方用户id", type = Excel.Type.ALL)
    private String sendUserid;

    @Excel(name = "接收方账号", type = Excel.Type.ALL)
    private String receiveUsername;

    @Excel(name = "接收方用户id", type = Excel.Type.ALL)
    private String receiveUserid;

    @Excel(name = "消息类型", type = Excel.Type.ALL, readConverterExp = "0=发送名片,1=发送私信,2=发送名片+私信")
    private String messageType;

    @Excel(name = "推送名片用户id", type = Excel.Type.ALL)
    private String shareUserid;

    @Excel(name = "消息内容", type = Excel.Type.ALL)
    private String messageContent;

    @Excel(name = "推广状态", type = Excel.Type.EXPORT, readConverterExp = "0=未发送,1=发送成功,2=失败重试,3=发送失败")
    private String status;

    @Excel(name = "失败重试次数", type = Excel.Type.EXPORT)
    private Integer failTimes;

    @Excel(name = "操作类型", type = Excel.Type.EXPORT, readConverterExp = "0=单发消息,1=批量发送")
    private String sendType;

    private String createBy;

    @Excel(name = "批次号", type = Excel.Type.EXPORT)
    private Long batchId;

    private String proxyServer;

    private String proxyPort;

    private String proxyCustomer;

    private String proxyPassword;

    public static InsMessage fromInsSendMessage(InsSendMessage sendMessage) {
        if (sendMessage == null) {
            return null;
        }
        InsMessage message = new InsMessage();
        message.setId(sendMessage.getId());
        message.setSendUsername(sendMessage.getSendUsername());
        message.setSendUserid(sendMessage.getSendUserid());
        message.setReceiveUsername(sendMessage.getReceiveUsername());
        message.setReceiveUserid(sendMessage.getReceiveUserid());
        message.setMessageType(sendMessage.getMessageType());
        message.setShareUserid(sendMessage.getShareUserid());
        message.setMessageContent(sendMessage.getMessageContent());
        message.setStatus(sendMessage.getStatus());
        message.setFailTimes(sendMessage.getFailTimes());
        message.setSendType(sendMessage.getSendType());
        message.setCreateBy(sendMessage.getCreateBy());
        message.setBatchId(sendMessage.getBatchId());
        message.setProxyServer(sendMessage.getProxyServer());
        message.setProxyPort(sendMessage.getProxyPort());
        message.setProxyCustomer(sendMessage.getProxyCustomer());
        message.setProxyPassword(sendMessage.getProxyPassword());
        // BaseEntity字段
        message.setCreateTime(sendMessage.getCreateTime());
        message.setUpdateTime(sendMessage.getUpdateTime());
        message.setUpdateBy(sendMessage.getUpdateBy());
        message.setRemark(sendMessage.getRemark());
        return message;
    }
}
